Skip to content

feat(id): identity_link table + link/unlink API (H2 of #9086, #14260) - #14418

Merged
developing-today-fleet[bot] merged 1 commit into
mainfrom
queue/23353-14260-h2-identity-link
Nov 24, 2026
Merged

developing-today-fleet[bot] merged 1 commit into
mainfrom
queue/23353-14260-h2-identity-link

Conversation

@developing-today-fleet

@developing-today-fleet developing-today-fleet Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

H2 of #9086 — identity_link table + link/unlink API

Implements slice H2 of the SSO relying-party design (doc/2026-11-24T04-50-00Z_design_sso-relying-party-9086/ §4.3 + §5), child issue #14260. Queue task 23353.

What

  • Migration tenancy/migrations/0002_identity_link.sql in the central tenancy DB (beside E's account/binding tables):
    • identity_link per the §4.3 DDL — one row per linked login door, provider_sub is the key (email never appears), UNIQUE (door, provider_sub) over all rows ("one account per door-identity, ever"), history rows retained with unlinked_at instead of deletes. Door vocabulary carries a CHECK (closed set, baseline precedent).
    • identity_link_event — append-only audit table (actor binding + timestamp for every link/unlink, §§4.3/4.8; the sketch DDL has no unlink-actor column, so the audit trail lives here — stated in the migration header).
    • meta.schema_version 1 → 2.
  • src/identity-link.ts — the store API over the same SQL seam the TenantOpsDO uses:
    • Link ceremony: authenticated session on the account + completed new-door proof; the actor must be the account's active binding; links only ever target the session's own account (first-link/account creation stays the provider's gated path, §4.4).
    • Last-door guard: the single active link cannot be unlinked without a replacement linked in the same operation; the replacement links first and a refused replacement aborts the swap untouched.
    • A door-identity claimed by another account is refused forever, even after unlink; the owning account re-linking reactivates its retained history row.
    • resolveAccountIdByDoor for the front door — takes the door explicitly, since (door, sub) is the key and no sub-only lookup is unambiguous.
    • Domain refusals are returned { ok: false, reason } (front-door style), never thrown, never partially applied.

Acceptance mapping (#14260)

Verification

  • test/identity-link.test.ts + test/tenancy-schema.test.ts: 17/17 pass (schema pins updated to the amended schema of record).
  • Full hosted-worker suite (npm test): 186/186 pass. bunx tsc --noEmit: clean.
  • Route note: tests ran on the laptop in the worktree — the fleet Actions exec runner has no credentials to check out this repo/branch, and repo CI runs on main only.

Dependency note

H1's front-door library is PR #14323 (open). This PR has no code dependency on it — the table shape is the design's — and lands behind no traffic per the design's rollout (§6). The front door wires resolveAccountIdByDoor in at H3.

Refs #14260

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-24T14:31:12Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": null,
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": null,
    "auth_subject": "archer",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Migration 0002 in the central tenancy DB: identity_link (per #9086
design s4.3; door vocabulary CHECK; UNIQUE (door, provider_sub) over
history — one account per door-identity, ever) + identity_link_event
append-only audit table; schema_version 1 -> 2.

src/identity-link.ts: the link/unlink store API — link ceremony
(authenticated session on the account + new-door proof; the actor
must be the account's active binding), last-door guard with
same-operation replacement, re-link reactivates the retained
history row, resolveAccountIdByDoor for the H1 front door. No
tenant row is written or read for effect: relinking cannot touch
tenant data (DB continuity, s4.3).

Tests: test/identity-link.test.ts (round-trip, guard refusal,
history retention, door-identity-ever, DB-continuity proof) +
tenancy-schema pins updated to the amended schema of record.
Full hosted-worker suite: 186/186 pass; tsc --noEmit clean.

Refs #14260
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 09beb3c7-422d-4251-934c-17592412827a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant